

const express = require('express') 
const path = require('path')
const bodyParser = require('body-parser')
const app = express()
// 配置body-parser 中间件 解析传递的参数
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use('/s',express.static(path.join(__dirname,'./public')))

app.get('/register',(req,res)=>{
    console.log(req.query);

    res.send(req.query)
})
app.post('/register',(req,res)=>{
    console.log(req.body);
    res.send(req.body)
})

let server = app.listen(3000,'127.0.0.1',()=>{
    let address = server.address().address
    let port = server.address().port
    console.log(`server is running hostname is ${address} port is ${port}`);
})